Skip to content

Conversation

@simonLeary42
Copy link
Collaborator

@simonLeary42 simonLeary42 commented Nov 10, 2025

OwnerMail2GID doesn't always return a GID. If no such owner mail is found, it returns the owner mail. This is confusing.

getUidFromEmail doesn't always return an LDAPEntry. If no such email is found, it returns no value. This makes my editor complain that "not all code paths return a value".

Also added a test to confirm that the error message is added to MODAL_ERRORS.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the ownerMail2GID() method to throw exceptions instead of returning the input unchanged when an email lookup fails. The change improves error handling by making it explicit when an email cannot be found in LDAP.

  • Modified ownerMail2GID() and getUidFromEmail() to throw EntryNotFoundException when email lookup fails
  • Added try-catch blocks in calling code to maintain backward-compatible behavior
  • Added test coverage for invalid PI email scenarios

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
resources/lib/exceptions/EntryNotFoundException.php New exception class for entry lookup failures
resources/lib/UnityLDAP.php Updated getUidFromEmail() to throw exception with added type hints and documentation
resources/lib/UnityGroup.php Updated ownerMail2GID() to throw exception instead of returning input unchanged
webroot/panel/new_account.php Added exception handling for email-to-GID conversion with fallback to existing validation
webroot/panel/groups.php Added exception handling for email-to-GID conversion with fallback to existing validation
resources/autoload.php Added autoload entry for new exception class
test/phpunit-bootstrap.php Added test bootstrap entry for new exception class
test/functional/PIMemberRequestTest.php Added test case for invalid PI email handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@simonLeary42 simonLeary42 mentioned this pull request Nov 10, 2025
@simonLeary42 simonLeary42 merged commit 0e64bdf into main Nov 10, 2025
9 checks passed
@simonLeary42 simonLeary42 deleted the refactor branch November 10, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants